/**
 * Copyright (C), 2019-2022, 宇信融汇
 * FileName: Publisher
 * Author:   666
 * Date:     2022/4/21 0:17
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 666           修改时间           版本号              描述
 */
package com.mashibing.hello;

import com.mashibing.util.RabbitMQConnectionUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import org.junit.Test;

/**
 * @Classname Publisher
 * @Description TODO
 * @Date 2022/4/21 0:17
 * @Created by 666
 */
public class Publisher {
    public static final String QUEUE_NAME = "hello";
    @Test
    public void publish() throws Exception {
        //1、创建connection
        Connection connection = RabbitMQConnectionUtil.getConnection();

        //2、创建管道channels
        Channel channel = connection.createChannel();
        //3、构建队列
        channel.queueDeclare(QUEUE_NAME, false, false, false, null);
        //4、发送消息
            String message = "hello";
            channel.basicPublish("",QUEUE_NAME,null,message.getBytes());
            System.out.println("生产者发送消息");
    }
}
